package com.codes.core.common.enumtype;

public enum WorkOrderState {



    // 0 待审核 1,通过 2.驳回3.修改 4配送 5完成',
    daishenhe((short)0, "待审核"),
    tongguo((short)1, "审核通过"),
    bohui((short)2, "驳回"),
    xiugai((short)3, "修改"),
    peisong((short)4, "配送"),
    wancheng((short)5, "完成");




    /** code */
    private short code;

    /** 显示标签 */
    private String label;

    /**
     * 构造器，必须私有
     * @param code
     */
    WorkOrderState(short code, String label){
        this.code = code;
        this.label = label;
    }

    /**
     * 获取code的文本
     * @param code
     * @return
     */
    public static String getLabelByCode (short code){
        for (WorkOrderState enuma : WorkOrderState.values()){
            if (enuma.getCode() == code){
                return enuma.getLabel();
            }
        }
        return "未知枚举项";
    }
    /**
     * 根据文本获取code
     */
    public static short getCodeByLabel(String label){
        for(WorkOrderState enuma : WorkOrderState.values()){
            if(enuma.getLabel().equals(label)){
                return enuma.getCode();
            }
        }
        return -1;

    }

    /**
     * 根据code获取枚举
     */
    public static WorkOrderState getRoleByCode(short code){
        for(WorkOrderState enuma : WorkOrderState.values()){
            if(enuma.getCode() == code){
                return enuma;
            }
        }
        return null;
    }

    public String toString(){
        return label;
    }

    public String getLabel() {
        return label;
    }

    public short getShort(){
        return this.code;
    }

    public short getCode(){
        return this.code;
    }


}
